<template>
  <div class="head">
    <div class="tit">
      <button class="tex1">中转差重报表</button>
    </div>
    <div class="line" />
    <el-row>
      <el-col :span="24">
        <div class="title1">
          <el-form
            ref="form"
            style="display: flex;flex-wrap: wrap;margin-top: 24px;justify-content: space-between;"
            :model="form"
            label-width="80px"
          >
            <div style="display: flex;justify-content: space-between;flex-wrap: wrap;width: 1568px;">
              <el-form-item class="text" label="网点名称">
                <el-select :disabled="true" class="input" placeholder="辽宁盘锦公司" style="width: 286px;">
                  <el-option label="辽宁盘锦公司" value="1" />
                </el-select>
              </el-form-item>
              <el-form-item class="text" label="第一直属航空部" label-width="110px">
                <el-select v-model="form.transferCentreId" class="input" placeholder="请选择" style="width: 254px;">
                  <el-option
                    v-for="item in TransferCenterList"
                    :key="item.id"
                    :label="item.transferCenter"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
              <el-form-item class="text" label="目的省份">
                <el-select
                  v-model="form.isShowProvince"
                  class="input"
                  placeholder="请选择"
                  style="width: 92px;"
                >
                  <el-option label="是" value="1" />
                  <el-option label="否" value="2" />
                </el-select>
                <el-select v-model="form.province" class="input" placeholder="请选择" style="width: 182px;margin-left: 12px;">
                  <el-option
                    v-for="item in ProvinceList"
                    :key="item.pid"
                    :label="item.province"
                    :value="item.province"
                  />
                </el-select>
              </el-form-item>
              <el-form-item class="text" label="汇总层级">
                <el-select v-model="form.collectType" class="input" placeholder="请选择" style="width: 286px;">
                  <el-option label="网点" value="1" />
                  <el-option label="第一直属航空部(中心)" value="2" />
                  <el-option label="网点+中心" value="3" />
                </el-select>
              </el-form-item>
            </div>
            <div>
              <el-form-item>
                <el-button type="primary" @click="onSubmit">查询</el-button>
                <el-button @click="khClear">重置</el-button>
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div class="title1">
          <el-form
            ref="form"
            style="display: flex;justify-content: space-between;flex-wrap: wrap;"
            :model="form"
            label-width="80px"
          >
            <div style="display: flex;justify-content: space-between;flex-wrap: wrap;width: 1568px;">
              <el-form-item class="text" label="日期">
                <el-date-picker
                  v-model="value"
                  type="daterange"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  value-format="yyyy-MM-dd"
                  style="width: 686px"
                  @change="changeTime"
                />
              </el-form-item>
              <el-form-item class="text" label="日期汇总层级" label-width="100px">
                <el-select v-model="form.dateType" class="input" placeholder="请选择" style="width: 286px;">
                  <el-option label="按天" value="1" />
                  <el-option label="按时间段" value="2" />
                </el-select>
              </el-form-item>
              <el-form-item class="text" label="明细导出类别 " label-width="100px">
                <el-select v-model="form.detailType" placeholder="请选择" style="width: 286px;">
                  <el-option label="大包明细" value="1" />
                  <el-option label="包内件明细" value="2" />
                </el-select>
              </el-form-item>
            </div>
            <div>
              <el-form-item>
                <el-button @click="onSubmit"><i class="el-icon-upload2" />导出</el-button>
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div class="line" />
        <div style="color: #EE3000;line-height: 40px;font-weight: 700;margin-top: 24px;">7月1日起查询数据以该报表数值为准</div>
        <el-table
          :data="tableData"
          border
          max-height="734"
          :header-cell-style="{ background: '#f6f6f6' }"
          style="width: 100%;margin-top: 19px;"
        >
          <el-table-column type="index" :index="table_index" width="50" align="center" />
          <el-table-column prop="settleDate" label="结算日期" width="180" align="center" />
          <el-table-column prop="networkName.networkName" label="网点名称" align="center" />
          <el-table-column prop="province" label="目的省份" align="center" />
          <el-table-column label="预收" align="center">
            <el-table-column prop="preTicketNum" label="票件量" align="center" />
            <el-table-column prop="preActualWeight" label="实际重量" align="center" />
            <el-table-column prop="preSettleWeight" label="结算重量" align="center" />
            <el-table-column prop="preSettleAmount" label="结算金额" align="center" />
          </el-table-column>
          <el-table-column label="调整" align="center">
            <el-table-column prop="adjustTicketNum" label="票件量" align="center" />
            <el-table-column prop="adjustActualWeight" label="实际重量" align="center" />
            <el-table-column prop="adjustSettleWeight" label="结算重量" align="center" />
            <el-table-column prop="adjustSettleAmount" label="调整金额" align="center" />
          </el-table-column>
          <el-table-column label="追溯" align="center">
            <el-table-column prop="ascendTicketNum" label="票件量" align="center" />
            <el-table-column prop="ascendActualWeight" label="实际重量" align="center" />
            <el-table-column prop="ascendSettleWeight" label="结算重量" align="center" />
            <el-table-column prop="ascendSettleAmount" label="调整差额" align="center" />
          </el-table-column>
          <el-table-column label="中转费" align="center">
            <el-table-column prop="totalAmount" label="合计金额" align="center" />
          </el-table-column>
        </el-table>
        <div style="display: flex;justify-content: space-between;margin-top: 51px;">
          <div class="title2" />
          <div class="block" style="display: flex; justify-content: flex-end">
            <el-pagination
              background
              :current-page="current"
              :page-sizes="[10, 20, 30, 40]"
              :page-size="10"
              layout="total, prev, pager, next"
              :total="+total"
              prev-text="上一页"
              next-text="下一页"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { getProvinceList } from '@/api/dashboard'
import { TransferCenterApi, DifferenceWeighApi } from '@/api/HqFinancePanel'
export default {

  components: {},
  data() {
    return {
      id: '1',
      ProvinceList: [], // 省
      cityList: [], // 市
      value: '',
      form: {
        collectType: '',
        dateType: '',
        detailType: '',
        endTime: '',
        isShowProvince: '',
        networkNameId: '1',
        pageDate: {
          pageNum: 1,
          pageSize: 10
        },
        province: '',
        startTime: '',
        transferCentreId: ''
      },
      mxForm: {
        destinationProvince: '',
        destinationCity: ''
      },
      tableData: [],
      current: '', // 页数
      pages: '', // 条数
      total: '', // 总数
      TransferCenterList: [] // 第一直属航空部列表
    }
  },

  computed: {},

  created() {
    this.getProvince()
    this.TransferCenter()
  },

  methods: {
    // 序号
    table_index(index) {
      return (this.pages - 1) * this.current + index + 1
    },
    // 选择时间
    changeTime() {
      this.form.startTime = this.value[0]
      this.form.endTime = this.value[1]
    },
    // 上一页
    handleSizeChange(val) {
      this.form.pageDate.pageSize = val
      this.onSubmit()
    },
    // 下一页
    handleCurrentChange(val) {
      this.form.pageDate.pageNum = val
      this.onSubmit()
    },
    // 获取省
    getProvince() {
      getProvinceList().then((res) => {
        if (res.code === 200) {
          this.ProvinceList = res.data
          console.log(res)
        }
      })
    },
    // 第一直属航空部
    async TransferCenter() {
      const res = await TransferCenterApi()
      this.TransferCenterList = res.data
    },
    // 重置
    khClear() {
      Object.keys(this.form).forEach((key) => {
        if (key !== 'pageDate' && key !== 'networkNameId') {
          this.form[key] = ''
        }
      })
      this.tableData = []
      this.value = ''
      this.total = ''
      this.current = ''
      this.pages = ''
    },
    // 查询
    async onSubmit() {
      const params = {}
      Object.keys(this.form).forEach(key => {
        if (this.form[key]) {
          params[key] = this.form[key]
        }
      })
      const res = await DifferenceWeighApi(params)
      this.tableData = res.data.data
      this.total = res.data.total
      this.current = res.data.current
      this.pages = res.data.pages
    }
  }
}

</script>
<style  scoped lang="scss">
.tit {
  display: flex;
  .tex1 {
    margin-right: 48px;
    font-size: 16px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;
    background: #fff;
    border: 1px #fff solid;
  }

  .active {
    font-family: Source Han Sans CN;
    font-weight: 700;
    color: #2087D0;
    position: relative;

  }

  .active::before {
    position: absolute;
    content: '';
    width: 110px;
    height: 2px;
    background: #2087D0;
    border-radius: 1px;
    bottom: -20px;
    left: 50%;
    transform: translate(-50%);
  }
}

.head {
  padding: 30px;
}

.title {
  font-size: 16px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
  margin-top: 20px;
}

.line {
  height: 1px;
  background: #D8D8D8;
  border-radius: 1px;
  margin-top: 19px;
}

.title1 {
   .text {
    font-size: 18px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;

    .input {
      width: 286px;
      height: 36px;
      background: #FFFFFF;
      border-radius: 4px;
    }

    .input1 {
      width: 708px;
      height: 36px;
      background: #FFFFFF;
      border: 1px solid #B4B4B4;
      border-radius: 4px;
    }
  }
}

.title2 {
  font-size: 18px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
}
</style>
